package com.xinhua.erp.pojo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.xinhua.erp.utils.JsonLongSerializer;

import javax.persistence.*;
import java.util.Set;

@Entity
public class Authority {

    @ManyToMany(cascade = CascadeType.REFRESH, mappedBy = "authoritySet", fetch = FetchType.LAZY)
    private Set<Role> roleSet;
    @Id
    @JsonSerialize(using = JsonLongSerializer.class)
    private Long id;

    private String name;

    private String description;

    public Long getId() {
        return id;
    }

    public void setId(Long id) { this.id = id; }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description == null ? null : description.trim();
    }

    public Set<Role> getRoleSet() {
        return roleSet;
    }

    public void setRoleSet(Set<Role> roleSet) {
        this.roleSet = roleSet;
    }
}